<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('库存结存列表')"/>
</head>
<style>
    .table-striped table thead tr th {
        border: 1px solid #ccc !important;
    }
</style>
<body>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label style="width: auto;">出入库时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginXiadanriqi]"
                                   th:value="${session.startTime}"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endXiadanriqi]"
                                   th:value="${session.endTime}"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" class="table table-bordered"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

    var prefix = ctx + "tongji/jiecun";
    $(function () {
        var options = {
            url: prefix + "/list",
            modalName: "结存统计表",
            showToggle: false,
            showColumns: false,
            pageSize: 100,
            columns: [
                [
                    {
                        field: 'shangpinguigekuan',
                        title: '商品规格宽',
                        align: "center",
                        colspan: 1, rowspan: 2
                    },
                    {
                        field: 'shangpinguigegao',
                        title: '商品规格高',
                        align: "center", colspan: 1, rowspan: 2
                    },
                    {
                        field: 'shangpinkaixiang',
                        title: '商品开向',
                        align: "center", colspan: 1, rowspan: 2
                    },
                    {
                        field: 'shangpinkucun',
                        title: '总库存',
                        align: "center", colspan: 1, rowspan: 2
                    },
                    {
                        title: '入库商品详情',
                        align: "center", colspan: 4, rowspan: 1
                    },
                    {
                        // field: 'xccunList',
                        title: '出库商品详情',
                        align: "center", colspan: 5, rowspan: 1
                    },
                    {
                        align: "center",
                        title: '库存详情', colspan: 5, rowspan: 1
                    },
                ],
                [
                    {
                        field: 'gccunList',
                        title: '入库时间',
                        align: "center",
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].dateIn + "<br>")
                                } else {
                                    list += (value[i].dateIn)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'gccunList',
                        title: '生产厂商',
                        align: "center",
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (value[i].shengchanchangshang == null) {
                                    list += ""
                                    continue
                                }
                                if (i !== value.length - 1) {
                                    list += (value[i].shengchanchangshang + "<br>")
                                } else {
                                    list += (value[i].shengchanchangshang)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'gccunList',
                        title: '商品名称',
                        align: "center", colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                var str = value[i].shangpinbianhao
                                if (str.indexOf("（") !== -1) {
                                    str = str.substring(str.indexOf("（") + 1, str.length - 1)
                                }
                                if (i !== value.length - 1) {
                                    list += (str + "<br>")
                                } else {
                                    list += (str)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'gccunList',
                        title: '入库数量',
                        align: "center", colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].shangpinshuliang + "<br>")
                                } else {
                                    list += (value[i].shangpinshuliang)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'xccunList',
                        title: '出库时间',
                        align: "center",
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].dateIn + "<br>")
                                } else {
                                    list += (value[i].dateIn)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'xccunList',
                        title: '出库单号',
                        align: "center", colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].danhao + "<br>")
                                } else {
                                    list += (value[i].danhao)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'xccunList',
                        title: '生产厂商',
                        align: "center",
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (value[i].shengchanchangshang == null) {
                                    list += ""
                                    continue
                                }
                                if (i !== value.length - 1) {
                                    list += (value[i].shengchanchangshang + "<br>")
                                } else {
                                    list += (value[i].shengchanchangshang)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'xccunList',
                        title: '出库商品',
                        align: "center", colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                var str = value[i].shangpinbianhao
                                if (str.indexOf("（") !== -1) {
                                    str = str.substring(str.indexOf("（") + 1, str.length - 1)
                                }
                                if (i !== value.length - 1) {
                                    list += (str + "<br>")
                                } else {
                                    list += (str)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'xccunList',
                        title: '出库数量',
                        align: "center", colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].shangpinshuliang + "<br>")
                                } else {
                                    list += (value[i].shangpinshuliang)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'jieCunList',
                        align: "center",
                        title: '商品名称', colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].shangpinming + "<br>")
                                } else {
                                    list += (value[i].shangpinming)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'jieCunList',
                        align: "center",
                        title: '生产厂商',
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].shengchanchangshang + "<br>")
                                } else {
                                    list += (value[i].shengchanchangshang)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'jieCunList',
                        align: "center",
                        title: '商品类别',
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].shangpinleibie + "<br>")
                                } else {
                                    list += (value[i].shangpinleibie)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'jieCunList',
                        align: "center",
                        title: '商品售价',
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].shangpinshoujia + "<br>")
                                } else {
                                    list += (value[i].shangpinshoujia)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    },
                    {
                        field: 'jieCunList',
                        align: "center",
                        title: '库存数量',
                        colspan: 1, rowspan: 1,
                        formatter: function (value, row, index) {
                            var actions = [];
                            var list = ""
                            for (let i = 0; i < value.length; i++) {
                                if (i !== value.length - 1) {
                                    list += (value[i].kucunshuliang + "<br>")
                                } else {
                                    list += (value[i].kucunshuliang)
                                }
                            }
                            actions.push(list)
                            return actions.join('');
                        }
                    }
                ]
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>